﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain
{
    public class Player
    {
        [Key]
        public int PlayerId { get; set; }
        [Required]
        public string Name { get; set; }
        public int Age { get; set; }
        

        public Player()
        {
        }

        public Player(string name, int age)
        {
            Name = name;
            Age = age;
            if (!IsValid())
            {
                throw new System.ApplicationException("Invalid Player Name");
            }
        }

        public bool IsValid()
        {
            return !Name.Any(a => char.IsDigit(a));
        }
    }
}
